package com.xxxx.seckill.utils;


import org.apache.commons.codec.digest.DigestUtils;

import java.util.UUID;

public class MD5Util {

    public static final String salt = "1a2b3c4d";

    public static String md5(String s){
        return DigestUtils.md5Hex(s);
    }

    public static String inputPassToFormPass(String inputPass) {
        String str = ""+salt.charAt(0)+salt.charAt(2) + inputPass
                +salt.charAt(5) + salt.charAt(4);
        return md5(str);
    }

    public static String formPassToDBPass(String formPass, String salt) {
        String str = ""+salt.charAt(0)+salt.charAt(2) + formPass +salt.charAt(5)
                + salt.charAt(4);
        return md5(str);
    }

    //直接调用此方法 --连续加密两次
    public static String inputPassToDbPass(String inputPass, String saltDB) {
        String formPass = inputPassToFormPass(inputPass);
        String dbPass = formPassToDBPass(formPass, saltDB);
        return dbPass;
    }

    public static void main(String[] args) {
        System.out.println(inputPassToFormPass("111111"));//d3b1294a61a07da9b49b6e22b2cb
//        System.out.println(formPassToDBPass(inputPassToFormPass("123456"),
//                "1a2b3c4d"));
//        System.out.println(inputPassToDbPass("d018506bc314a32b93eb214102399a63", "1a2b3c4d"));
//        UUID uuid = UUID.randomUUID();
//        String  node = uuid.toString();
//        System.out.println(uuid.getLeastSignificantBits());
//        System.out.println(node);
    }
}



